import Vue from 'vue'
import Router from 'vue-router'

import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)
const router = new Router({
    routes: [{
            path: '/',
            name: 'root',
            // hidden: true,
            meta: { hidden: true },
            // redirect: '/qylb',
            component: () =>
                import ('@/view/Advertising/Advertising.vue')
        },
        {
            path: '/home',
            name: 'Home',
            meta: { title: '团餐', icon: 'iconfont icon-riqixuanze' },
            component: () =>
                import ('@/pages/footer/home/index.vue'),
            children: [{
                    path: '/GoldChef',
                    name: 'GoldChef',
                    component: () =>
                        import ('@/pages/footer/home/GoldChef.vue')
                },
                {
                    path: '/dishes',
                    name: 'Dishes',
                    component: () =>
                        import ('@/pages/footer/home/view2/dishes/index.vue')
                }, {
                    path: '/fruit',
                    name: 'Fruit',
                    component: () =>
                        import ('@/pages/footer/home/view2/fruit/index.vue')
                }, {
                    path: '/catering',
                    name: 'Catering',
                    component: () =>
                        import ('@/pages/footer/home/view2/catering/index.vue')
                }
            ]
        },
        {
            path: '/meal',
            name: 'Meal',
            meta: { title: '福利餐', icon: 'iconfont icon-youhuiquan-01' },
            component: () =>
                import ('@/pages/footer/meal/index.vue')
        },
        {
            path: '/order',
            name: 'Order',
            meta: { title: '订单', icon: 'iconfont icon-wodedingdan' },
            component: () =>
                import ('@/pages/footer/order/index.vue'),
            beforeEnter: (to, from, next) => {
                if (localStorage.getItem('deng') == null) {
                    next({ path: '/login' })
                } else {
                    next()
                }
            }
        },
        {
            path: '/my',
            name: 'My',
            meta: { title: '我的', icon: 'iconfont icon-wode' },
            component: () =>
                import ('@/pages/footer/my/index.vue'),
            beforeEnter: (to, from, next) => {
                if (localStorage.getItem('deng') == null) {
                    next({ path: '/login' })
                } else {
                    next()
                }
            }
        },
        {
            path: '/login',
            name: 'Login',
            meta: { title: ' ' },

            hidden: true,
            component: () =>
                import ('@/pages/login/login.vue')
        },
        {
            path: '/register',
            name: 'Register',
            meta: { title: ' ' },
            hidden: true,
            component: () =>
                import ('@/pages/login/register.vue')
        },
        {
            path: '/edit',
            name: 'Edit',
            meta: { title: ' ' },
            hidden: true,
            component: () =>
                import ('@/pages/footer/my/Edit/edit.vue'),
            beforeEnter: (to, from, next) => {
                if (localStorage.getItem('deng') == null) {
                    // next({ path: '/login' })
                    to({ path: '/login' })
                } else {
                    next()
                }
            }
        },
        {
            path: '/delect_alert',
            name: 'Delect_alert',
            meta: { title: ' ' },
            hidden: true,
            component: () =>
                import ('@/pages/footer/my/Edit/delect_alert.vue')
        },
        {
            path: '/integral',
            name: 'Integral',
            meta: { title: ' ' },
            hidden: true,
            component: () =>
                import ('@/pages/tu/integral.vue')
        },
        {
            path: '/points',
            name: 'Points',
            meta: { title: ' ' },
            hidden: true,
            component: () =>
                import ('@/pages/tu/points.vue')
        },
        {
            path: '/community',
            name: 'Community',
            meta: { title: ' ' },
            hidden: true,
            component: () =>
                import ('@/pages/tu/community.vue')
        },
        {
            path: '/myMoney',
            name: 'MyMoney',
            meta: { title: ' ' },
            hidden: true,
            component: () =>
                import ('@/pages/tu/myMoney.vue')
        },
        {
            path: '/settled',
            name: 'Settled',
            meta: { title: ' ' },
            hidden: true,
            component: () =>
                import ('@/pages/tu/settled.vue')
        },
        {
            path: '/qylb',
            name: 'qylb',
            meta: { title: '企业列表' },
            component: () =>
                import ('../components/dongzhen/qylb/qylb.vue')
        },
        {
            path: '/fwxy',
            name: 'fwxy',
            meta: { title: '服务协议' },
            component: () =>
                import ('@/components/dongzhen/fwxy/fwxy.vue')
        },
        {
            path: '/shequ',
            name: 'shequ',
            hidden: true,
            // meta: { title: '服务协议' },
            component: () =>
                import ('@/pages/footer/meal/shequ/shequ.vue')
        },
        {
            path: '/sccs',
            name: 'sccs',
            meta: { title: '收藏厨师' },
            component: () =>
                import ('@/components/dongzhen/sccs/sccs.vue')
        },
        {
            path: '/tcdz',
            name: 'tcdz',
            meta: { title: '团餐定制', footerNav: true },
            component: () =>
                import ('@/components/dongzhen/tcdz/tcdz.vue'),
            redirect: '/djd',
            children: [{
                    path: '/djd',
                    name: 'djd',
                    meta: { title: '待接单', footer: true, nowIndex: 0 },
                    component: () =>
                        import ('@/components/dongzhen/tcdz/modules/djd.vue')
                },
                {
                    path: '/fwz',
                    name: 'fwz',
                    meta: { title: '服务中', footer: true, nowIndex: 1 },
                    component: () =>
                        import ('@/components/dongzhen/tcdz/modules/fwz.vue')
                },
                {
                    path: '/ywc',
                    name: 'ywc',
                    meta: { title: '已完成', footer: true, nowIndex: 2 },
                    component: () =>
                        import ('@/components/dongzhen/tcdz/modules/ywc.vue')
                },
            ]
        },
        {
            path: '/yysc',
            name: 'yysc',
            meta: { title: '预约试吃', footerNav: true },
            component: () =>
                import ('@/components/dongzhen/yysc/yysc.vue'),
            redirect: '/dsh',
            children: [{
                    path: '/dsh',
                    name: 'dsh',
                    meta: { title: '待审核', footer: true, nowIndex: 0 },
                    component: () =>
                        import ('@/components/dongzhen/yysc/modules/dsh.vue')
                },
                {
                    path: '/dps',
                    name: 'dps',
                    meta: { title: '待配送', footer: true, nowIndex: 1 },
                    component: () =>
                        import ('@/components/dongzhen/yysc/modules/dps.vue')
                },
                {
                    path: '/ywcs',
                    name: 'ywcs',
                    meta: { title: '已完成', footer: true, nowIndex: 2 },
                    component: () =>
                        import ('@/components/dongzhen/yysc/modules/ywc.vue')
                },
            ]
        }
    ]
})

export default router;